package com.jzy.bxb.model.mongo.entity;

import java.util.Date;
import java.util.List;

import org.mongodb.morphia.annotations.Embedded;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
import org.mongodb.morphia.annotations.Indexed;

/**
 * 用户
 *
 * @author JiangZhiYong
 * @date 2017-06-22 QQ:359135103
 */
@Entity(value = "user", noClassnameStored = true)
public class User {

	@Id
	private long id;
	/**账号*/
	private String userName;
	
	/**密码*/
	private String password;
	
	/**手机*/
	private String phone;
	
	/** 会话ID */
	@Indexed
	private String sid;
	
	/**用户类型*/
	private int userType;
	
	/**用戶地址*/
	private Address address;
	
	/**
	 * 设备唯一编号
	 */
	private String deviceToken;
	
	/**幫手地址*/
	@Embedded
	private List<Address> assistantAddress;
	
	/**创建时间*/
	private Date createTime;
	
	
	/**登录时间*/
	private Date loginTime;
	
	/**平台*/
	private String platform;
	
	/**是否为管理员*/
	private boolean admin;
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getSid() {
		return sid;
	}

	public void setSid(String sid) {
		this.sid = sid;
	}

	public Address getAddress() {
		return address;
	}

	public void setAddress(Address address) {
		this.address = address;
	}

	public int getUserType() {
		return userType;
	}

	public void setUserType(int userType) {
		this.userType = userType;
	}

	public List<Address> getAssistantAddress() {
		return assistantAddress;
	}

	public void setAssistantAddress(List<Address> assistantAddress) {
		this.assistantAddress = assistantAddress;
	}

	public String getDeviceToken() {
		return deviceToken;
	}

	public void setDeviceToken(String deviceToken) {
		this.deviceToken = deviceToken;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getLoginTime() {
		return loginTime;
	}

	public void setLoginTime(Date loginTime) {
		this.loginTime = loginTime;
	}

	public String getPlatform() {
		return platform;
	}

	public void setPlatform(String platform) {
		this.platform = platform;
	}
	
	
	public boolean isAdmin() {
		return admin;
	}

	public void setAdmin(boolean admin) {
		this.admin = admin;
	}

	/**
	 * 是否为iOS
	 * @return
	 */
	public boolean isIOS(){
		if(this.platform==null||!this.platform.equalsIgnoreCase("ios")){
			return false;
		}
		return true;
	}
}
